﻿using Microsoft.Extensions.DependencyInjection;
using Stee.CAP8.MessageBus.Message;
using Stee.CAP8.MessageBus.Message.Orders;
using System;
using test.kafka.usercode;

namespace test.kafka.Order
{
    class Program
    {
        static void Main(string[] args)
        {
            var services = new ServiceCollection();
            services
                .AddEventBus()
                .AddRebusHandler<OrderHandler>()
                .UseEventBus(bus =>
                {
                    bus.AddSubscrbe<OrderCreationEvent>(services);
                });


            services.AddSingleton(typeof(IOrderService), typeof(OrderService));

            var orderService = services.BuildServiceProvider().GetService<IOrderService>();
            var orderinfo = new OrderInfo() 
            {
                Id = Guid.NewGuid(),
                Name ="苹果8plus"
            };

            orderService.CreateOrder(orderinfo);
            //while (true) 
            //{

            //}
            Console.Read();
        }
    }
}
